<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Trim Avisynth Filter</title>
<link rel="stylesheet" type="text/css" href="../../avisynth.css">
</head>
<body>
<h2>Trim / AudioTrim</h2>
<p><code>Trim </code>(<var>clip, int first_frame, int last_frame [, bool "pad"]</var>)<br>
<code>Trim </code>(<var>clip, int first_frame, int -num_frames [, bool "pad"]</var>)<br>
<code>Trim </code>(<var>clip, int first_frame, int "end" [, bool "pad"]</var>)<br>
<code>Trim </code>(<var>clip, int first_frame, int "length" [, bool "pad"]</var>)</p>
<p><code>AudioTrim </code>(<var>clip, float start_time, float end_time</var>)<br>
<code>AudioTrim </code>(<var>clip, float start_time, float -duration</var>)<br>
<code>AudioTrim </code>(<var>clip, float start_time, float "end"</var>)<br>
<code>AudioTrim </code>(<var>clip, float start_time, float "length"</var>)</p>
<p><code>Trim</code> trims a video clip so that it includes only the frames <var>first_frame</var>
 up to <var>last_frame</var> (<var>first_frame</var>
 and <var>last_frame</var> are included). The audio is similarly trimmed so that
it stays synchronized. Remember AviSynth starts counting at frame 0.</p>
<p>Prior to v2.60, to trim an audio-only clip, you may not just set a fake
frame rate with <a href="assumerate.htm" title="AssumeFPS">AssumeFPS</a>.
Instead, you must make a <a href="blankclip.htm" title="BlankClip">BlankClip</a>,
use <a href="audiodub.htm" title="AudioDub">AudioDub</a>, trim <i>that</i>, and
then <a href="killaudio.htm" title="KillVideo">KillVideo</a>. Otherwise,
AviSynth returns an error message &quot;cannot trim if there is no video&quot;.</p>
<p>Since v2.60 you can trim the audio using <code>AudioTrim</code>. The <var>start_time</var>,
<var>end_time</var> and <var>duration</var> need to be specified in seconds (but
can be float). Like <code>Trim</code> it keeps only the audio samples
corresponding to <var>start_time</var> up to <var>end_time</var>. The target
source clip does not need to have a video track. If present the video is
similarly trimmed so that it stays synchronized within 1 frame duration.</p>
<p><var>pad </var> (default true) causes the audio stream to be padded to
align with the video stream. Otherwise the tail of a short audio stream is left
so. When <var> last_frame</var>=0 and <var>pad</var>=false the end of the
two streams remains independent.</p>
<p>Since v2.60 you can also use AudioTrim/Trim(3, end=7) instead of
AudioTrim/Trim(3, 7) and AudioTrim/Trim(3, length=7) instead of
AudioTrim/Trim(3, -7). Note, the End and Length explicitly named parameters
have no discontinuous boundary values. End=0 means end at frame 0.  Length=0
means return a zero length clip. These are most useful in avoiding unexpected
boundary conditions in your user functions.</p>
<p><b>Examples:</b></p>
<pre>Trim(100,0)             # delete the first 100 frames, audio padded
                        # or trimmed to match the video length.
Trim(100,0,false)       # delete the first 100 frames of audio and video,
                        # the resulting stream lengths remain independent.
Trim(100,-100)          # is the same as trim(100,199)
Trim(100,199,false)     # audio will be trimmed if longer but not
                        # padded if shorter to frame 199
Trim(0,-1)              # returns only the first frame
Trim(0,End=0)           #
Trim(0,Length=1)        #
AudioTrim(1,5.5)        # keeps the audio samples between 1 and 5.5 seconds
AudioTrim(1,End=5.5)    #
AudioTrim(1,-5.5)       # cuts the first second and keeps the following 5.5 seconds
AudioTrim(1,Length=5.5) #</pre>
<p><b>Changelog:</b></p>
<table border="1">
  <tbody>
    <tr>
      <td>v2.60</td>
      <td>Added AudioTrim. Added explicit length and end parameters.</td>
    </tr>
    <tr>
      <td>v2.56</td>
      <td>added pad audio</td>
    </tr>
  </tbody>
</table>
<p><kbd>$Date: 2012/04/15 14:59:42 $</kbd></p>
<FORM>
<INPUT TYPE="Button" VALUE="Back"
onClick="history.go(-1)">
</form>
</body>
</html>
